package com.example.lenovo.serviceandroid;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        Toolbar toolbar = (Toolbar) findViewById(R.id.toolBar);

        //设置 APP logo
//        toolbar.setLogo(R.mipmap.ic_launcher);

        //设置主标题，默认为 app_label
        toolbar.setTitle("微信");
        //设置主标题文字颜色
        toolbar.setTitleTextColor(getResources().getColor(R.color.whilt));

//        //设置副标题
//        toolbar.setSubtitle("副标题");
//        //设置副标题颜色
//        toolbar.setSubtitleTextColor(getResources().getColor(R.color.colorPrimaryDark));


        //设置侧边栏（抽屉）的按钮
        toolbar.setNavigationIcon(R.drawable.normal_back);
        //取代原本的 Actionbar
        setSupportActionBar(toolbar);


        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_item_share:
                Toast.makeText(MainActivity.this, "分享", Toast.LENGTH_SHORT).show();
                break;

            case R.id.menu_item_about:
                Toast.makeText(MainActivity.this, "关于", Toast.LENGTH_SHORT).show();
                break;

            case R.id.menu_item_more:
                Toast.makeText(MainActivity.this, "更多", Toast.LENGTH_SHORT).show();
                break;
        }
        return true;
    }
}
